package interfaz.dialog;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle;
import javax.swing.SwingUtilities;

import tiposEnumerados.EstadoVivienda;
import tiposEnumerados.TipoVivienda;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class PreguntaDialog extends javax.swing.JDialog {
	private boolean respuesta;
	private TipoVivienda tipo;
	private EstadoVivienda estado;
	private JLabel labelPregunta1;
	private AbstractAction accionNo;
	private AbstractAction accionSi;
	private JButton botonNO;
	private JButton botonSI;
	private JLabel labelPregunta3;
	private JLabel labelPregunta2;
	private JLabel labelPregunta;

	/**
	* Auto-generated main method to display this JDialog
	*/
		
	public PreguntaDialog(JFrame frame, TipoVivienda tipo, EstadoVivienda estado, boolean cual) {
		super(frame);
		this.setModal(true);
		if(cual){//true es estado
			this.estado=estado;
			this.tipo=null;
		}else{//false es tipo
			this.tipo=tipo;
			this.estado=null;
		}
		initGUI();
		this.setVisible(true);
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			{
				labelPregunta = new JLabel();
				
				labelPregunta.setText("Desea que en adelante se descarten");
			}
			{
				labelPregunta1 = new JLabel();
				labelPregunta1.setText("todos los resultados que contengan");
			}
			{
				labelPregunta2 = new JLabel();
				String pregunta;
				if(this.tipo==null){
					pregunta="estado de la vivienda ";
				}else{
					pregunta="tipo de la vivienda ";
				}
				labelPregunta2.setText(pregunta+"con valor");
			}
			{
				labelPregunta3 = new JLabel();
				String pregunta2;
				if(this.tipo==null){
					pregunta2=estado.toString();
				}else{
					pregunta2=tipo.toString();
				}
				labelPregunta3.setText(pregunta2);
			}
			{
				botonSI = new JButton();
				botonSI.setText("Si");
				botonSI.setAction(getAccionSi());
			}
			{
				botonNO = new JButton();
				botonNO.setText("No");
				botonNO.setAction(getAccionNo());
			}
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(43, 43)
				.addComponent(labelPregunta, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addComponent(labelPregunta1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(labelPregunta2, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(labelPregunta3, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)
				.addGap(45)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(botonSI, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(botonNO, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE))
				.addContainerGap(41, 41));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(57, 57)
				.addGroup(thisLayout.createParallelGroup()
				    .addGroup(thisLayout.createSequentialGroup()
				        .addComponent(labelPregunta, GroupLayout.PREFERRED_SIZE, 244, GroupLayout.PREFERRED_SIZE))
				    .addGroup(thisLayout.createSequentialGroup()
				        .addComponent(labelPregunta1, GroupLayout.PREFERRED_SIZE, 244, GroupLayout.PREFERRED_SIZE))
				    .addGroup(thisLayout.createSequentialGroup()
				        .addComponent(labelPregunta2, GroupLayout.PREFERRED_SIZE, 244, GroupLayout.PREFERRED_SIZE))
				    .addGroup(thisLayout.createSequentialGroup()
				        .addComponent(labelPregunta3, GroupLayout.PREFERRED_SIZE, 244, GroupLayout.PREFERRED_SIZE))
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(botonSI, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE)
				        .addGap(88)
				        .addComponent(botonNO, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE)))
				.addContainerGap(83, Short.MAX_VALUE));
			setSize(400, 300);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private AbstractAction getAccionSi() {
		if(accionSi == null) {
			accionSi = new AbstractAction("Si", null) {
				public void actionPerformed(ActionEvent evt) {
					setRespuesta(true);
					dispose();
				}
			};
		}
		return accionSi;
	}
	
	private AbstractAction getAccionNo() {
		if(accionNo == null) {
			accionNo = new AbstractAction("No", null) {
				public void actionPerformed(ActionEvent evt) {
					setRespuesta(false);
					dispose();
				}
			};
		}
		return accionNo;
	}
	
	public void setRespuesta(boolean siono){
		this.respuesta=siono;
	}
	
	public boolean getRespuesta(){
		return this.respuesta;
	}

}
